<form class="layui-form" action="{:url()}" method="post" id="editForm">
   <div class="layui-form-item">
   <div class="layui-inline upload" style="width:280px; padding-left:30px;">
        <button type="button" name="upload" class="layui-btn layui-btn-primary layui-upload" lay-type="image" lay-data="{exts:'jpg|png|gif|bmp|jpeg', accept:'images'}">请上传产品图</button>
        <input type="hidden" class="upload-input" name="pic" value="{:arrayGet($formData, 'pic', '')}">
        {if condition="arrayGet($formData, 'pic', '') != ''"}
        <img src="{:arrayGet($formData, 'pic', '')}" style="display:inline-block;border-radius:5px;border:1px solid #ccc" width="36" height="36">
        {else /}
        <img src="" style="display:none;border-radius:5px;border:1px solid #ccc" width="36" height="36">
        {/if}
    </div>
    {:FormExt::setInline()}
    {:FormExt::input('物料名称', 'name', '', '请输入物料名称', 'required', 'lay-verify="required"')}
    {:FormExt::select('物料类型', 'type', '', config('mimo.material_type'), '', '')}
    {:FormExt::select('单位', 'unit', '米', $unitKV, '', '')}
    {:FormExt::input('内部sku', 'self_sku', '', '内部sku', '', '')}
<!--    {:FormExt::select('采购单位', 'purchasing_unit', '', $unitKV, '', '')}-->
    {:FormExt::input('型号', 'model', '', '请输入型号', '', '')}
    {:FormExt::input('色号', 'colornum', '', '请输入色号', '', '')}
    {:FormExt::input('颜色', 'color', '', '请输入颜色', '', '')}
    {:FormExt::input('规格', 'format', '', '请输入规格', '', '')}
    {:FormExt::input('幅宽', 'fabric_width', '', '请输入规格', '', '')}
    {:FormExt::input('克重', 'weight', '', '请输入规格', '', '')}
    {:FormExt::input('客户单价', 'customer_price', '', '请输入客户单价', '', 'lay-verify="number"')}
    {:FormExt::input('实际采购单价', 'price', '', '请输入实际采购单价', '')}
    {:FormExt::input('供应商', 'supplier', '', '请输入供应商', '', '')}
    {:FormExt::input('联系方式', 'contact', '', '请输入联系方式', '', '')}
    {:FormExt::input('地址', 'address', '', '请输入地址', '', '')}
    {:FormExt::radio('是否需验布', 'need_checkcloth', '', ['0' => '否', '1' => '是', '2' => '不作判断'], '', '')}
    {:FormExt::radio('是否需缩水', 'need_shrink', '', ['0' => '否', '1' => '是', '2' => '不作判断'], '', '')}
    </div>
    <div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="id">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
<script src="__PUBLIC_JS__/jquery.2.1.4.min.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js?v={:config('hisiphp.version')}"></script>
<script>
    var formData = {:json_encode($formData)};
    layui.use(['form', 'func', 'jquery', 'upload', 'layer', 'tool'], function() {
        $ = layui.jquery;
        var form = layui.form;
        var laytpl = layui.laytpl,laydate=layui.laydate ,table = layui.table;
        var upload = layui.upload;
        var layer = layui.layer;
        layui.func.assign(formData);

        //图片上传
        upload.render({
            elem: '.layui-upload',
            url: '{:url("system/annex/upload?thumb=no&water=no&full_path=true")}'
            ,method: 'post'
            ,before: function(input) {
                layer.msg('文件上传中...', {time:3000000});
            },done: function(res, index, upload) {
                var obj = this.item;
                if (res.code == 0) {
                    layer.msg(res.msg);
                    return false;
                }
                layer.closeAll();
                var input = $(obj).parents('.upload').find('.upload-input');
                if ($(obj).attr('lay-type') == 'image') {
                    input.siblings('img').attr('src', res.data.file).show();
                }
                input.val(res.data.file);
            }
        });
    });
</script>